#!/bin/bash
# 快速构建脚本 - 集成所有优化配置

echo "🚀 开始快速构建停车场管理系统..."

# 设置环境变量
export JAVA_HOME=/Users/fish/Library/Java/JavaVirtualMachines/jbr-17.0.11/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export MAVEN_OPTS="-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC"

# 运行版本检查
echo "📋 环境检查..."
./maven-version-check.sh

# 清理旧的构建缓存
echo "🧹 清理构建缓存..."
find ~/.m2/repository -name "*.lastUpdated" -delete 2>/dev/null || true

# 并行构建项目
echo "⚡ 开始并行构建..."
echo "使用兼容的Maven编译器插件版本..."
mvn clean install -DskipTests -T 1C -U

# 检查结果
if [ $? -eq 0 ]; then
    echo "✅ 构建成功！"
    echo ""
    echo "🎯 现在可以启动项目:"
    echo "  ./quick-start.sh"
    echo ""
    echo "或手动启动:"
    echo "  mvn spring-boot:run -Dspring-boot.run.profiles=dev -pl park-admin"
else
    echo "❌ 构建失败，请检查错误信息"
    echo ""
    echo "🔍 故障排除:"
    echo "  1. 检查网络连接"
    echo "  2. 运行: mvn clean install -U"
    echo "  3. 查看BUILD_OPTIMIZATION.md获取更多帮助"
fi